Option Explicit
Sub F_Sample051()
    'Microsoft DAO 3.6 Object Library ]wޥζ
    Dim myWsp  As DAO.Workspace
    Dim myCon  As DAO.Connection
    Dim myRst  As DAO.Recordset
    Dim myCnc1 As String
    Dim myCnc2 As String
    Dim myCnc3 As String
    Dim myCmd  As String
    Dim i      As Long
    myCnc1 = "ODBC;"
    myCnc2 = "Driver=SQL Server;"
    'wnsA
    myCnc3 = "SERVER=SERVERNAME;UID=sa;PWD=;DATABASE=mysample;FILEDSN=C:"
    'HSQLԭzӫwno
    myCmd = "SELECT * FROM mysample.dbo.F_Tbl01"
    Set myWsp = CreateWorkspace("myWsp", "myName", "", dbUseODBC)
    Workspaces.Append myWsp					'u@sW
    Set myCon = myWsp.OpenConnection( _
        Name:="myConnection", _
        Options:=dbDriverNoPrompt, _
        Connect:=myCnc1 & myCnc2 & myCnc3)
    Set myRst = myCon.OpenRecordset(myCmd)
    Worksheets.Add
    With myRst
        'W
        For i = 1 To .Fields.Count
            Cells(1, i).Value = .Fields(i - 1).Name
        Next
        'O
        Range("A2").CopyFromRecordset myRst
        .Close
    End With
    myCon.Close
    myWsp.Close
    Set myRst = Nothing					'
    Set myCon = Nothing
    Set myWsp = Nothing
End Sub
